package com.jzo2o.customer.controller.operation;

import com.jzo2o.common.model.CurrentUserInfo;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.WorkerCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.RejectReasonResDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationAuditResDTO;
import com.jzo2o.customer.service.IWorkerCertificationService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @Description WorkCertificationAuditController
 * @Author loe
 * @Date 2024-08-14
 */
@RestController("operationWorkerCertificationAuditController")
@RequestMapping("/operation/worker-certification-audit")
@Api(tags = "运营端 - 服务人员认证审核相关接口")
public class WorkCertificationAuditController {
    @Autowired
    private IWorkerCertificationService workerCertificationService;

    @GetMapping("page")
    @ApiOperation("审核服务人员认证分页查询")
    public PageResult<WorkerCertificationAuditResDTO> page(WorkerCertificationAuditPageQueryReqDTO reqDTO) {
        return workerCertificationService.getPage(reqDTO);
    }

    @PutMapping("audit/{id}")
    @ApiOperation("审核服务人员认证信息")
    public void audit(
            @PathVariable(value = "id", required = true) Long id,
            @RequestParam(value = "certificationStatus", required = true) Integer certificationStatus,
            @RequestParam(value = "rejectReason", required = false) String rejectReason) {
        CurrentUserInfo currentUserInfo = UserContext.currentUser();
        Long userId = currentUserInfo.getId();
        String name = currentUserInfo.getName();
        workerCertificationService.audit(id, certificationStatus, rejectReason, userId, name);
    }
}
